#include <cmath>

class Solution {
public:
    int mySqrt(int x) {
        if (x == 0) {
            return 0;
        }
        double t = x;
        while (true) {
            double next_t = 0.5f * (t + x / t);
            if (fabs(t - next_t) < 1e-5) {
                break;
            }
            t = next_t;
        }
        return (int) t;
    }
};

int main() {
    Solution solution;
    solution.mySqrt(2147395599);
    return 0;
}
